Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closes #4334: sphinx-apidoc: References to non-existing files in TOC #4335

Merged
merged 1 commit into from
Jan 1, 2018
Merged

Closes #4334: sphinx-apidoc: References to non-existing files in TOC #4335

merged 1 commit into from
Jan 1, 2018

Conversation

zufallsgenerator
Copy link
Contributor

@zufallsgenerator zufallsgenerator commented Dec 21, 2017

Subject: Don't generate references to non-existing files in in TOC of python packages or modules

Feature or Bugfix

  • Bugfix

Purpose

  • Don't generate references to non-existing files in TOC of package modules when encountering a directory only containing an empty init.py. This is decided in the method shall_skip in apidoc.py, so changing the behaviour there to include directories with empty init.py would still make this fix valid.

Detail

Relates

@@ -116,7 +116,12 @@ def create_package_file(root, master_package, subroot, py_files, opts, subs, is_
text += '\n'

# build a list of directories that are szvpackages (contain an INITPY file)
subs = [sub for sub in subs if path.isfile(path.join(root, sub, INITPY))]
# and also checks the INITPY file is not empty, or there are other python
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

an empty INITPY is still a valid INITPY making the directory a package as opposed to namespace

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True. But before this patch there would be a reference to that package, although the package .rst file would never be created. It seems to have been the behaviour of apidoc.py since many years to exclude those packages.

See:

sphinx/sphinx/apidoc.py

Lines 159 to 169 in 87cebf1

if INITPY in py_files:
# we are in package ...
if (# ... with subpackage(s)
subs
or
# ... with some module(s)
len(py_files) > 1
or
# ... with a not-to-be-skipped INITPY file
not shall_skip(path.join(root, INITPY))
):

That's why I'm reluctant to change an existing deliberate design, but tried to fix the inconsistency. If we change the behaviour in apidoc.py to not skip empty init.py files in shall_skip it'd still be consistent. @birkenfeld ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good.

Copy link
Member

@tk0miya tk0miya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also feel the skip for empty __init__.py is strange. But it is the default behavior of apidoc. So let's keep this as is. :-p

@tk0miya tk0miya merged commit 023dad6 into sphinx-doc:stable Jan 1, 2018
@tk0miya
Copy link
Member

tk0miya commented Jan 1, 2018

Thank you for contribution!

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants